<template>
  <a-card :bordered="false" class="card-area">

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="handleEditAdd(record)">编辑</a>
          <a-divider type="vertical" />
        </span>


      </a-table>
    </div>

    <a-modal
      title='配置数量'
      :visible='wishConfigV'
      @ok='wishConfigOk'
      @cancel='wishConfigV=false'
      cancelText='取消'
      okText='确定'
    >
      <a-textarea placeholder='请输入配置数量' v-model='wishConfig.configNum' />
    </a-modal>

  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JDate from '@/components/jeecg/JDate'
  import { postAction } from '@api/manage'

  export default {
    name: "RoleList",
    mixins:[JeecgListMixin],
    components: {
      JDate
    },
    data () {
      return {
        wishConfigV:false,
        description: '用户任务列表页面',
        wishConfig:{configNum:''},
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title: '编码，对应业务',
            align:"center",
            dataIndex: 'code'
          },
          {
            title: '配置数量',
            align:"center",
            dataIndex: 'configNum'
          },
          {
            title: '配置名称',
            align:"center",
            dataIndex: 'name'
          },
          {
            title: '创建时间',
            dataIndex: 'createTime',
            align:"center",
            sorter: true
          },
          {
            title: '更新时间',
            dataIndex: 'updateTime',
            align:"center",
            sorter: true
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/wishConfig/list",
          editUrl: "/wishConfig/edit",
        },
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      handleEditAdd: function(rec){
        this.wishConfig =rec;
        this.wishConfigV = true
      },
      wishConfigOk(){
        postAction(this.url.editUrl, this.wishConfig).then(({ success, result, message }) => {
          if (success) {
            this.loadData()
            this.$message.success(message)
          } else {
            this.$message.warning(message)
          }
        }).finally(() => this.wishConfigV = false)
      }


    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>